package ms.jasim.pddl;

import ms.jasim.framework.IConfiguration;
import ms.jasim.framework.JasimFramework;
import ms.jasim.model.JasimModel;

public class PddlProblemGenerator {
	
	@SuppressWarnings("unchecked")
	public static PddlProblem generate(JasimModel model) {
		IConfiguration configuration = JasimFramework.getConfiguration();
		String generator = null;
		if (configuration != null)
			generator = configuration.getString(IConfiguration.GENERATOR, null);
		if (generator != null) {
			try {
				Class genClass = Class.forName(generator);
				return generate(genClass, model);
			} catch (Exception e) {
				return null;
			}
		}
		return null;
	}
	
	public static PddlProblem generate(Class<? extends IPddlProblemGenerator> genClass, JasimModel model) {
		try {
			IPddlProblemGenerator instance = genClass.newInstance();
			return instance.getPddlProblem(model);
		} catch (Exception e) {
			return null;
		}
	}
	
}
